package com.判断路线成圆;

import java.util.HashMap;

class Solution {
    public boolean judgeCircle(String moves) {
        char[] c  = moves.toCharArray();
        HashMap<Character,Integer> hm = new HashMap<Character,Integer>();
        
        for(int i =0;i<moves.length();i++){
            if(hm.containsKey(c[i])){
                hm.put(c[i],hm.get(c[i])+1);
            }
            else{
                hm.put(c[i],1);
            }
        }
        int D = hm.get('D')==null?0:hm.get('D');
        int U = hm.get('U')==null?0:hm.get('U');
        int L = hm.get('L')==null?0:hm.get('L');
        int R = hm.get('R')==null?0:hm.get('R');
        if(D==U&&L==R)
            return true;
        else
            return false;
    }
}
